package com.marvin.config;

import com.marvin.handle.LoginInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author yinyin
 * @create 2021/11/20 下午 4:26
 */
@Configuration
public class WebMvcConfiguration implements WebMvcConfigurer {
    //注入自定义的拦截器
    @Bean
    public LoginInterceptor getLoginInterceptor(){
        return  new LoginInterceptor();
    }


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(getLoginInterceptor())
                //规定拦截哪些路径
                .addPathPatterns("detail/**","/","/index");
                //排除哪些接口不被拦截
               //  .excludePathPatterns("/");
    }
}
